﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TestSystem.BLL.Profile;
using TestSystem.BLL.TestSystem;

public partial class Controls_QuizInfoPanel : System.Web.UI.UserControl
{
    private Quiz currentQuiz = null;
    public Quiz CurrentQuiz
    {
        get { return currentQuiz; }
        set { currentQuiz = value; }
    }
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            lnkSubject.NavigateUrl = String.Format(lnkSubject.NavigateUrl, CurrentQuiz.SubjectID);
            lnkSubject.Text = CurrentQuiz.Title;
            lblAddedDate.Text = CurrentQuiz.AddedDate.ToString();
            lblAuthor.Text = ((CustomProfile)CurrentQuiz.Author).Personal.FirstName + " " + ((CustomProfile)CurrentQuiz.Author).Personal.LastName;
            lblCount.Text = CurrentQuiz.QuestionsCount.ToString();
            lblPassed.Text = CurrentQuiz.PassedTimes.ToString();
            lblSaveAnswers.Text = CurrentQuiz.SaveUserAnswers ? "тік" : "ні";
            lblTimePerQuiz.Text = ((int) (CurrentQuiz.TimePerQuiz/60)) + "хв";
            lblTotalTaken.Text = (CurrentQuiz.PassedTimes + CurrentQuiz.FailedTimes).ToString();
            lblTotalCount.Text = Test.GetCountByQuizID(CurrentQuiz.QuizID).ToString();
            lblScoreToPass.Text = CurrentQuiz.ScoreToPass.ToString();
        }
    }
}
